SET NOCOUNT ON
SET QUOTED_IDENTIFIER ON
GO

PRINT '-- Member Users'

BEGIN TRAN

	DECLARE @I INT = 0
	DECLARE @NUM INT = 0
	SELECT @NUM = COUNT(*) FROM tblPersons

	WHILE @I < @NUM
	BEGIN
		SET @I = @I + 1
		
		IF EXISTS (SELECT * FROM tblPersons WHERE prs_ID = @I AND prs_State = 'Speler' AND prs_Active = 1 AND prs_Username IS NULL)
			EXEC sptblPersons_CreateLogin @prs_ID = @I
	END
	
COMMIT TRAN